<template>
  <div class="tree">
    <el-tree :data="treeList" :props="defaultProps" node-key="id" :current-node-key="checkid" :highlight-current="true"
      default-expand-all @node-click="handleNodeClick"></el-tree>
  </div>
</template>
<script>
import { getOrgList } from '@/api/common'
export default {
  data() {
    return {
      defaultProps: {
        children: 'children',
        label: 'orgName'
      },
      treeList: [],
      checkid: '1'
    }
  },
  methods: {
    handleNodeClick(data) {
      this.$emit('selectTree', data)
      this.checkid = data.id
      console.log(this.checkid)
    },
    async handleTree() {
      const { code, data } = await getOrgList()
      if (code == 1) {
        this.treeList = data
        this.$emit('normalSelectTree', this.treeList)
      }
    }
  },
  created() {
    this.handleTree()
  }
}
</script>
<style lang="less" scoped>
:deep( .el-tree ) {
  width: 100%;
}

.tree {
  width: 100%;

  /*.el-tree--highlight-current,
  .el-tree-node.is-current > .el-tree-node__content {
    background-color: #becdde;
  }*/
}
</style>
